﻿@{
    ViewBag.Title = "Update";
    Layout = "~/Views/Shared/_Admin_Layout.cshtml";
    ViewBag.Controller = "account";
    ViewBag.Cate = "Thành viên";
    ViewBag.Module = "Register User";
}

<script type="text/javascript">
    $(function () {
        $('#_btn_add').live('click', function () {
            var username = $("#_username").val();
            var password = $("#_password").val();
            var email    = $("#_email").val();
            var fullname = $("#_fullname").val();

            //Check Username
            if (username.length > 5) {
                if (checkInp(username, '', 'username')) {

                } else {
                    show_errors("Tên đăng nhập không hợp lệ.");
                    return false;
                }
            } else {
                show_errors("Tên đăng nhập phải lớn hơn 5 ký tự.");
                return false;
            }
            @{if (ViewBag.View == null)
            {
                //Check Password
                @:if (password.length <= 5) {
                    @:show_errors("Mật khẩu phải lớn hơn 5 ký tự.");
                    @:return false;
                @:}
            }}

            //Check Email
            if (email != '') {
                if (checkInp(email, '', 'email')) {

                } else {
                    show_errors("Email không hợp lệ.");
                    $(".notice").stop().slideDown(200);
                    return false;
                }
            } else {
                show_errors("Chưa nhập email");
                return false;
            }

            //Check Fullname
            if (fullname == '') {
                show_errors("Chưa nhập họ và tên.");
                return false;
            }

            UpdateItem("@ViewBag.Controller");

            return false;
        });
    });
</script>

<!--Tabs-->
<div class="tabs">
    <span class="item"><a href="/admin" title="">Bảng điều khiển</a></span>
    <span class="icon-arrow">&gt;</span>
    <span class="item"><a href="/admin/@ViewBag.Controller" title="">@ViewBag.Cate</a></span>
    <span class="icon-arrow">&gt;</span>
    <span class="item">Cập nhật</span>
</div>
<!--End Tabs-->

<!--Container-->
<div class="container">
	<form class="table-content" id="_PostData" method="post">
        <div class="list-btn">
            <a href="/admin/@ViewBag.Controller" class="btn btn-primary" title="Danh sách">Danh sách</a>
            @if (ViewBag.View == null)
            { 
                <input type="submit" class="btn btn-success" id="_btn_add" value="Lưu" />
            }
            else
            {
                <input type="submit" class="btn btn-warning" id="_btn_add" value="Cập nhật" />
            }
        </div>
        <div class="clearAll"></div>
        <div class="notice"><span class="close-notice icon-remove"></span></div>
		<div class="title"><span class="icon-user"></span>@ViewBag.Module</div>
		<div class="error"></div>
		<div class="box-field">
            <input type="hidden" name="id" id="_id" value="@if (ViewBag.View != null){ @ViewBag.View.id }"/>
            <table class="altrowstable" id="alternatecolor">
                <tr>
                    <th>Tên Field</th><th>Input Field</th>
                </tr>
                <tr>
                    <td>Tên đăng nhập</td>
                    <td><input type="text" name="username" id="_username" value="@if (ViewBag.View != null){ @ViewBag.View.username }" placeholder="Ex: onepro166" maxlength="50" /></td>
                </tr>
                <tr>
                    <td>Mật khẩu</td>
                    <td><input type="password" name="password" id="_password" value="" placeholder="Ex: 123456" /></td>
                </tr>
                <tr>
                    <td>Email</td>
                    <td><input type="text" name="email" id="_email" value="@if (ViewBag.View != null){ @ViewBag.View.email }" placeholder="Ex: example@gmail.com" /></td>
                </tr>
                <tr>
                    <td>Họ Tên</td>
                    <td><input type="text" name="fullname" id="_fullname" value="@if (ViewBag.View != null){ @ViewBag.View.fullname.Trim() }" placeholder="Ex: Phạm Tiến" /></td>
                </tr>
                <tr>
                    <td>Ngày sinh</td>
                    <td><input type="text" name="birthday" id="_birth" value="@if (ViewBag.View != null && ViewBag.View.birthday != null){ @ViewBag.View.birthday.ToString("dd/MM/yyyy") }" placeholder="Ex: 16/06/1992"  /></td>
                </tr>
                <tr>
                    <td>Điện thoại</td>
                    <td><input type="text" name="phone" id="_phone" value="@if (ViewBag.View != null && @ViewBag.View.phone != null){ @ViewBag.View.phone.Trim() }" data-type="int" maxlength="11" placeholder="Ex: 0912345678" /></td>
                </tr>
                <tr>
                    <td>Địa chỉ</td>
                    <td><input type="text" name="address" id="_address" class="span5" value="@if (ViewBag.View != null){ @ViewBag.View.address }" placeholder="Ex: 123Bis, CMT8, Q.10, Tp.HCM" /></td>
                </tr>
                <tr>
                    <td>Trạng thái</td>
                    <td><input type="checkbox" name="status" id="_status" value="1" @if (ViewBag.View != null && @ViewBag.View.status == 1) { Write("checked"); } /></td>
                </tr>
                <tr>
                    <td>Nhận Email từ BQT</td>
                    <td><input type="checkbox" name="sendmail" id="_sendmail" checked value="1" @if (ViewBag.View != null && @ViewBag.View.sendmail == 1) { Write("checked"); } /></td>
                </tr>
            </table>
		</div>
	</form>         
</div>
<!--End Container-->